<!doctype html> 
<html> 
<head> 
    <meta charset="utf-8"> 
    <title>  生成器函数 </title> 
</head>
<body>

<script>

function fn(){
	var a = 10;
	function show2(){
		return a;
	};
	return show2()
}

console.log("fn----------------", fn());

const obj = {
	set Leo(v){
		console.log("obj------------set----------", v);
	},
	get Leo(){
		return {
			b:20,
			set Leo(v){
				console.log("obj------------get-------", this.b)
			}
		}
	}
};

obj.Leo.Leo = 5;
obj.Leo = 10
obj.Leo = 10;

console.log("obj.Leo------------", typeof obj.Leo)


const objTest = {
	a(){
		console.log("objTest---a-this---------", this);
	},
	b(){
		return this;
	}
};

objTest.c = objTest.b();
console.log("objTest------------", objTest);

objTest.a();

// 生成器函数
function* show(){
	//alert(this);
	yield function (){
		console.log("生成器函数-----------1---", 1);
	}
	yield function (){
		console.log("生成器函数-----------2---", 2);
	}
	yield function(){
		document.body.style.background = 'black';
	}

};

const showNext = show();
showNext.next().value();
showNext.next().value();
showNext.next().value();

// show().next();
// console.log(show());
</script>
</body>
</html>